/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author stumbledog
 */
@Entity
@Table(name = "fantasymatch")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Fantasymatch.findAll", query = "SELECT f FROM Fantasymatch f"),
    @NamedQuery(name = "Fantasymatch.findByleagueId", query = "SELECT f FROM Fantasymatch f WHERE f.leagueId = :leagueId"),
    @NamedQuery(name = "Fantasymatch.findByleagueIdweekId", query = "SELECT f FROM Fantasymatch f WHERE f.leagueId = :leagueId and f.weekId = :weekId"),
    @NamedQuery(name = "Fantasymatch.findById", query = "SELECT f FROM Fantasymatch f WHERE f.id = :id"),
    @NamedQuery(name = "Fantasymatch.findByHomeScore", query = "SELECT f FROM Fantasymatch f WHERE f.homeScore = :homeScore"),
    @NamedQuery(name = "Fantasymatch.findByAwayScore", query = "SELECT f FROM Fantasymatch f WHERE f.awayScore = :awayScore")})
public class Fantasymatch implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "homeScore")
    private Float homeScore;
    @Column(name = "awayScore")
    private Float awayScore;
    @JoinColumn(name = "weekId", referencedColumnName = "id")
    @ManyToOne
    private Week weekId;
    @JoinColumn(name = "leagueId", referencedColumnName = "id")
    @ManyToOne
    private Fantasyleague leagueId;
    @JoinColumn(name = "homeTeamId", referencedColumnName = "id")
    @ManyToOne
    private Fantasyteam homeTeamId;
    @JoinColumn(name = "awayTeamId", referencedColumnName = "id")
    @ManyToOne
    private Fantasyteam awayTeamId;
    @OneToMany(mappedBy = "fantasyMatchId")
    private Collection<Fantasyplayoff> fantasyplayoffCollection;

    public Fantasymatch() {
    }

    public Fantasymatch(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Float getHomeScore() {
        return homeScore;
    }

    public void setHomeScore(Float homeScore) {
        this.homeScore = homeScore;
    }

    public Float getAwayScore() {
        return awayScore;
    }

    public void setAwayScore(Float awayScore) {
        this.awayScore = awayScore;
    }

    public Week getWeekId() {
        return weekId;
    }

    public void setWeekId(Week weekId) {
        this.weekId = weekId;
    }

    public Fantasyleague getLeagueId() {
        return leagueId;
    }

    public void setLeagueId(Fantasyleague leagueId) {
        this.leagueId = leagueId;
    }

    public Fantasyteam getHomeTeamId() {
        return homeTeamId;
    }

    public void setHomeTeamId(Fantasyteam homeTeamId) {
        this.homeTeamId = homeTeamId;
    }

    public Fantasyteam getAwayTeamId() {
        return awayTeamId;
    }

    public void setAwayTeamId(Fantasyteam awayTeamId) {
        this.awayTeamId = awayTeamId;
    }

    @XmlTransient
    public Collection<Fantasyplayoff> getFantasyplayoffCollection() {
        return fantasyplayoffCollection;
    }

    public void setFantasyplayoffCollection(Collection<Fantasyplayoff> fantasyplayoffCollection) {
        this.fantasyplayoffCollection = fantasyplayoffCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Fantasymatch)) {
            return false;
        }
        Fantasymatch other = (Fantasymatch) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return ("entities.Fantasymatch[ id=" + id + " ]" 
                + " weekId:" + weekId 
                + ", leagueId" + leagueId 
                + ", homeTeam:" + homeTeamId.getName() 
                + ", score: " + homeScore
                + ", awayTeam:" + awayTeamId.getName()
                + ", score:" + awayScore);
    }
    
}
